<ui:composition template="/pages/templates/layout.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="title">Enregistrement des interviews</ui:define>
	<ui:define name="content">
		<h:form id="form">
			<p:messages id="messages" showDetail="true" autoUpdate="true"
				closable="true" />

			<p:panel id="toggleable" header="ENREGISTREMENT DES INTERVIEWS"
				toggleable="true" toggleSpeed="500" widgetVar="panel">
				<p:fieldset id="saisie" legend="Saisie des informations"
					toggleable="true" toggleSpeed="500">
					<h:panelGrid columns="3" cellpadding="10">
						<p:outputLabel for="journaliste" value="Journaliste" />
						<p:autoComplete id="journaliste"
							value="#{journalistePersonnaliteBean.selectedJournalisteCombo}"
							completeMethod="#{journalistePersonnaliteBean.completeJournaliste}"
							var="jrliste" itemLabel="#{jrliste.journalisteNom}"
							itemValue="#{jrliste}" converter="#{entityConverter}"
							dropdown="true" forceSelection="true" required="true"
							binding="#{journalistePersonnaliteBean.fieldJliste}"
							effect="bounce" styleClass="select">
							<p:ajax update="journalisteMsg" event="query" global="false" />
						</p:autoComplete>
						<p:message id="journalisteMsg" for="journaliste" display="icon" />

						<p:outputLabel for="personnalite" value="Personnalite" />
						<p:autoComplete id="personnalite"
							value="#{journalistePersonnaliteBean.selectedPersonnaliteCombo}"
							completeMethod="#{journalistePersonnaliteBean.completePersonnalite}"
							var="prslite"
							itemLabel="#{prslite.personnaliteNom} #{prslite.personnalitePrenom}"
							itemValue="#{prslite}" converter="#{entityConverter}"
							dropdown="true" forceSelection="true" required="true"
							binding="#{journalistePersonnaliteBean.fieldPlite}"
							effect="bounce" styleClass="select">
							<p:ajax update="personnaliteMsg" event="query" global="false" />
						</p:autoComplete>
						<p:message id="personnaliteMsg" for="personnalite" display="icon" />

						<p:outputLabel for="jrltePersDate" value="Date interview" />
						<p:calendar id="jrltePersDate"
							value="#{journalistePersonnaliteBean.currentJournalistePersonnalite.jrltePersDate}"
							locale="fr" navigator="true" showButtonPanel="true"
							effect="bounce" required="true" pattern="dd/MM/yyyy">
							<p:ajax update="jrltePersDateMsg" event="keyup" />
						</p:calendar>
						<p:message id="jrltePersDateMsg" for="jrltePersDate"
							display="icon" />
					</h:panelGrid>

					<p:separator />

					<p:commandButton value="Enrégistrer"
						binding="#{journalistePersonnaliteBean.btnSave}"
						action="#{journalistePersonnaliteBean.saveJournalistePersonnalite}"
						icon="ui-icon-disk" update="@all">
						<p:confirm header="Confirmation"
							message="Voulez-vous enrégistrer ?" icon="ui-icon-alert" />
					</p:commandButton>
					<p:commandButton value="Modifier"
						binding="#{journalistePersonnaliteBean.btnUpdate}"
						action="#{journalistePersonnaliteBean.updateJournalistePersonnalite}"
						icon="ui-icon-refresh" update="@all" disabled="true">
						<p:confirm header="Confirmation" message="Voulez-vous modifier ?"
							icon="ui-icon-alert" />
					</p:commandButton>
					<p:commandButton value="Supprimer"
						binding="#{journalistePersonnaliteBean.btnDelete}"
						action="#{journalistePersonnaliteBean.deleteJournalistePersonnalite}"
						icon="ui-icon-trash" update="@all" disabled="true">
						<p:confirm header="Confirmation" message="Voulez-vous supprimer ?"
							icon="ui-icon-alert" />
					</p:commandButton>
					<p:commandButton value="Annuler"
						action="#{journalistePersonnaliteBean.resetField}"
						icon="ui-icon-cancel" update=":form:saisie" />

					<p:confirmDialog global="true" showEffect="puff"
						hideEffect="explode">
						<p:commandButton value="Oui" type="button"
							styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
						<p:commandButton value="Non" type="button"
							styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
					</p:confirmDialog>
				</p:fieldset>

				<p:dataTable id="table" var="interview"
					value="#{journalistePersonnaliteBean.journalistePersonnalites}"
					selection="#{journalistePersonnaliteBean.selectedJournalistePersonnaliteTable}"
					selectionMode="single" rowKey="#{interview.id}"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					paginator="true" rows="10" rowsPerPageTemplate="5,10,15"
					styleClass="table">
					<p:ajax event="rowSelect"
						listener="#{journalistePersonnaliteBean.updateField}"
						update=":form:saisie" />
					<p:column headerText="Journalistes" styleClass="column">
						<h:outputText value="#{interview.journaliste.journalisteNom}" />
					</p:column>

					<p:column headerText="Personnalités" styleClass="column">
						<h:outputText
							value="#{interview.personnalite.personnaliteNom} #{interview.personnalite.personnalitePrenom}" />
					</p:column>

					<p:column headerText="Dates interviews" styleClass="column">
						<h:outputText value="#{interview.jrltePersDate}">
							<f:convertDateTime pattern="dd-MM-yyyy" />
						</h:outputText>
					</p:column>
				</p:dataTable>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>
